module SuppliersHelper
  
  def add_filter_link(name, id)
    if id.nil?
      filter = Filter.new
    else
      filter = Filter.new(Filter.find(id).attributes)
    end
    link_to_function name do |page|
      page.remove "filterForm"
      
      if id.nil?
        page.insert_html :top, "filters", :partial => 'filter', :locals => { :filter => filter }
      else
        page.insert_html :after, "filter" + id.to_s, :partial => 'filter', :locals => { :filter => filter }
      end
    end
  end
  
end
